package leetcode.offer_two_special.array;

/**
 * @author mazouri
 * @create 2021-09-04 22:24
 */
public class _05_maxProduct {
    public int maxProduct(String[] words) {
        int res = 0;
        for (int i = 0; i < words.length - 1; i++) {
            for (int j = i + 1; j < words.length; j++) {
                if (!isSame(words[i], words[j])) {
                    res = Math.max(res,words[i].length() * words[j].length());
                }
            }
        }

        return res;
    }

    public boolean isSame(String a, String b) {
        for (char ch : a.toCharArray()) {
            if (b.indexOf(ch) != -1) return true;
        }
        return false;
    }
}
